import grails.test.*

class BookInstanceTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testCreation() {
        mockDomain(BookInstance,[])
        BookInstance book = new BookInstance()
        assertFalse book.validate()
        assertEquals "nullable", book.errors["profile"]
        assertEquals 'nullable', book.errors["status"]
        assertEquals 'nullable', book.errors['owner']

        book.profile = new BookProfile(name:'fight club')
        book.status=' '
        book.owner = new User()
        assertFalse book.validate()
        assertNull book.errors['owner']
        assertNull book.errors['profile']
        assertEquals 'blank', book.errors['status']

        book.status='CLOSED'
        assertFalse book.validate()
        assertEquals 'inList', book.errors['status']

        book.status='OPEN'
        assertTrue book.validate()
    }
}
